//填充
export const TypeDock = {
	//  上
	TOP: 'top',
	// 下
	BOTTOM: 'bottom',
	// 左
	LEFT: 'left',
	// 右
	RIGHT: 'right',
	//居中铺满
	FILL: 'fill'
}
let kw = 'width',
	kh = 'height';
export function hDock(dom, dock, w, h) {
	let _style = dom.style;
	let _h = h;
	let _w = w;

	function hTop() {
		_style.setProperty(TypeDock.TOP, '0px');
	}

	function hBottom() {
		_style.setProperty(TypeDock.BOTTOM, '0px');
	}

	function hLeft() {
		_style.setProperty(TypeDock.LEFT, '0px');
	}

	function hRight() {
		_style.setProperty(TypeDock.RIGHT, '0px');
	}


	function hWidth() {
		hLeft();
		hRight();
	}

	function hHeight() {
		hTop();
		hBottom();
	}

	function hFill() {
		hWidth();
		hHeight();
	}

	function hRemove(k, sk, s) {
		_style.removeProperty(k);
		if (sk) {
			_style.setProperty(sk, s + 'px');
		}
	}

	switch (dock) {
		case TypeDock.TOP:
			hRemove(kw);
			hRemove(TypeDock.BOTTOM, kh, _h);
			hTop();
			hWidth();
			break;
		case TypeDock.BOTTOM:
			hRemove(kw);
			hRemove(TypeDock.TOP, kh, _h);
			hBottom();
			hWidth();
			break;
		case TypeDock.LEFT:
			hRemove(kh);
			hHeight();
			hLeft();
			hRemove(TypeDock.RIGHT, kw, _w);
			break;
		case TypeDock.RIGHT:
			hRemove(kh);
			hRemove(TypeDock.LEFT, kw, _w);
			hHeight();
			hRight();
			break;
		case TypeDock.FILL:
			hRemove(kh);
			hRemove(kw);
			hFill();
			break;
		default:
			break;
	}

}
